package easycloud.ecs.common.domain;

import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.MappedSuperclass;
import javax.persistence.OneToMany;
import javax.validation.constraints.NotNull;

import org.springframework.data.jpa.domain.AbstractPersistable;

@SuppressWarnings("serial")
@MappedSuperclass
public abstract class AbstractFolder extends AbstractPersistable<Integer> {

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "userid")
	private User user;

	@NotNull
	@Column(name = "name", nullable = false, length = 200)
	private String name;

	@OneToMany(cascade = { CascadeType.PERSIST, CascadeType.MERGE }, fetch = FetchType.LAZY, mappedBy = "folder")
	private Set<Sync> syncs = new HashSet<Sync>();

	@OneToMany(cascade = { CascadeType.PERSIST, CascadeType.MERGE }, fetch = FetchType.LAZY, mappedBy = "folder")
	private Set<Item> items = new HashSet<Item>();

	public Set<Item> getItems() {
		return items;
	}

	public String getName() {
		return name;
	}

	public Set<Sync> getSyncs() {
		return syncs;
	}

	public User getUser() {
		return user;
	}

	public void setItems(Set<Item> items) {
		this.items = items;
	}

	public void setName(String name) {
		this.name = name;
	}

	public void setSyncs(Set<Sync> syncs) {
		this.syncs = syncs;
	}

	public void setUser(User user) {
		this.user = user;
	}
}
